<?php
namespace app\admin\model;
use think\Model;
class Notice extends Model
{
	//添加公告内容
	public function adds(){
       $data = input('post.');
       $data['content'] = input('post.content');
       if($data['content']){
       	  $data['create_time'] = date('Y-m-d H:i:s');
       	  $notice = db('notice')->insert($data);
          if($notice){
          	$content = '添加公告';
	        admin_log($content); 
          	 return ['code'=> 1,'msg' => '添加成功'];
          }else{
          	 return ['code' => 0,'msg' => '添加失败'];
          }
       }else{
       	  return ['code' => 0,'msg' => '请填写内容'];
       }
	}

	//编辑公告内容
	public function edits(){
		$id = input('param.id');
		$data = input('post.');
		$data['content'] = input('post.content');
		if($data['content']){
			$data['update_time'] = date('Y-m-d H:i:s');
       	    $notice = db('notice')->update($data);
            if($notice){
            	$content = '编辑公告';
	        	 admin_log($content); 
          	     return ['code'=> 1,'msg' => '修改成功'];
            }else{
          	     return ['code' => 0,'msg' => '修改失败'];
            }
		}else{
			 return ['code' => 0,'msg' => '请填写内容'];
		}
		dump($id);
		exit;
	}
}